//
//  JsonModel.swift
//  JSON
//
//  Created by LiynXu on 2016/9/30.
//  Copyright © 2016年 LiynXu. All rights reserved.
//

import Foundation

class JsonModel: NSObject {
    var showapi_res_code:NSNumber = 0
    var showapi_res_error:String = ""
    var showapi_res_body:BodyModel?
    func initWithDict(dict:Dictionary<String,AnyObject>) -> JsonModel{
        let json = JsonModel()
        json.showapi_res_code = dict["showapi_res_code"] as! NSNumber
        json.showapi_res_error = dict["showapi_res_error"] as! String
        json.showapi_res_body = BodyModel().initWithDict(dict["showapi_res_body"] as! Dictionary<String,AnyObject>)
        return json
    }
}

class BodyModel: NSObject {
    var ret_code:NSNumber = 0
    var pagebean:PagebeanModel = PagebeanModel()
    func initWithDict(dict:Dictionary<String,AnyObject>) -> BodyModel{
        let body = BodyModel()
        body.ret_code = dict["ret_code"] as! NSNumber
        body.pagebean = PagebeanModel().initWithDict(dict["pagebean"] as! Dictionary<String,AnyObject>)
        return body
    }
    
}

class PagebeanModel: NSObject {
    var allPages:NSNumber = 0
    var currentPage:NSNumber = 0
    var allNum:NSNumber = 0
    var maxResult:NSNumber = 0
    var contentlist = Array<ContentModel>()
    func initWithDict(dict:Dictionary<String,AnyObject>) -> PagebeanModel{
        var model = PagebeanModel()
        
        model.allPages = dict["allPages"] as! NSNumber
        model.allNum = dict["allNum"] as! NSNumber
        model.currentPage = dict["currentPage"]  as! NSNumber
        model.maxResult = dict["maxResult"] as! NSNumber
        
        let dataArray = dict["contentlist"] as! Array<Dictionary<String,AnyObject>>
        
        for item in dataArray {
            let content = ContentModel().initWithDict(item)
            model.contentlist.append(content)
        }
        
        return model
    }
   
}
class ContentModel: NSObject {
   var  date = ""
   var  weixinNum = ""
    var url = ""
    var typeName = ""
    var id = ""
    var title = ""
    var contentImg = ""
    var userLogo = ""
    var userName = ""
    var read_num:NSNumber = 0
    var like_num:NSNumber = 0
    var typeId = ""
    var userLogo_code = ""
    
    func initWithDict(dict:Dictionary<String,AnyObject>) -> ContentModel{
        let content = ContentModel()
        content.date = dict["date"] as! String
        content.url = dict["url"] as! String
        content.weixinNum = dict["weixinNum"] as! String
        content.typeName = dict["typeName"] as! String
        content.id = dict["id"] as! String
        content.title = dict["title"] as! String
        content.contentImg = dict["contentImg"] as! String
        content.userLogo = dict["userLogo"] as! String
        content.userName = dict["userName"] as! String
        content.read_num = dict["read_num"] as! NSNumber
        content.like_num = dict["like_num"] as! NSNumber
        content.typeId = dict["typeId"] as! String
        //content.userLogo_code = dict["userLogo_code"] as! String
        
        return content
    }
}






